package com.core.web.initial;

import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.commons.logging.*;

/**
 * 系统初始化 ServletContextListenter，初始化装载系统配置信息
 * 
 * @author Administrator
 * 
 */
public class InitialContextListener implements ServletContextListener {
	private static Log log = LogFactory.getLog(InitialContextListener.class);

	public void contextDestroyed(ServletContextEvent e) {

	}

	public void contextInitialized(ServletContextEvent e) {
		/**
		 * 系统参数配置类缓存装载
		 */
		loadConfiguration(e.getServletContext().getRealPath(""));
		/**
		 * 通用缓存信息缓存装载
		 */
		loadSelectFromXML();
	}

	/**
	 * 系统参数配置类缓存装载
	 */
	private void loadConfiguration(String uploadFolder) {
		ConfigurationLoad load = new ConfigurationLoad();
		load.parser("/configuration.xml", uploadFolder);
	}

	// 加载SelectFromXML.xml配置文件
	private void loadSelectFromXML() {
		log.info("DownLoad selectfromxml.xml file......");
		SelectFromXMLLoad load = new SelectFromXMLLoad();
		load.parserXML("/selectfromxml.xml");
	}
}
